<?php

	class TimeAction extends Action{

	/*获取内容列表*/
	public function checkList($countWhere,$dataWhere,$order){
		import("@.ORG.Page");
		$count = M('News')->where($countWhere)->count('id');
		$p     = new Page ($count,C('listnews'));
		$list = M()->Table(array(C('DB_PREFIX').'news'=>'news',C('DB_PREFIX').'user'=>'user'))->where($dataWhere)->order($order)->limit($p->firstRow.','.$p->listRows)->select();
		$p->setConfig('theme','%totalRow% %header% %first% %prePage% %linkPage% %nextPage% %end%');
		$page = $p->show();
		foreach($list as $key=>$value){
			$list[$key]['title'] = $value['title'];
			$list[$key]['face'] = C('YICMS_PUBLIC').'/face/f_'.$value['face'];
			$list[$key]['mpic'] = C('URL').'/Public/news/m_'.$value['pic'];
			$list[$key]['spic'] = C('URL').'/Public/news/s_'.$value['pic'];
			if(!empty($value['tag'])) $list[$key]['tag'] = explode(' ',$value['tag']);
			if(C('opencws')){
				$list[$key]['content'] = preg_replace('/yi_show\((.*?),event\)/',"yi_show(\\1,event,".$value['id'].")",$value['content']);
			}else{
				$list[$key]['content'] = strip_tags($value['content']);
			}
		}
		
		if(!empty($list)) $this->assign('count',$count);
		else $this->assign('count',0);
		
		$this->assign('list',$list);
		$this->assign('page',$page);
	}

	/*穿越*/
	public function history(){
		
		$agent = $_SERVER['HTTP_USER_AGENT']; 
		$str="/YiCms/Tpl/Home/".C('DEFAULT_THEME')."/Public/";
		$this->assign('style',$str);
		$time = (int)$_GET['_URL_'][2];
		if(empty($time)) $time = date('Y').date('m').date('d');
		//网站配置
		$config = M('Config')->find();
		if($_GET['p']){
			$config['title'] = $time.'-穿越-第'.(int)$_GET['p'].'页-'.$config['stitle'];
		}else{
			$config['title'] = $time.'-穿越-'.$config['stitle'];
		}
		$this->assign('config',$config);
		
		$year = substr($time,0,4);
		$month = substr($time,4,2);
		$day = substr($time,6,2);
		$startTime = mktime(0,0,0,$month,$day,$year);
		$stopTime  = mktime(23,59,59,$month,$day,$year);
		$countWhere = "state=1 AND time>'$startTime' AND time<'$stopTime'";
		$dataWhere  = "news.state = 1 AND news.uid = user.uid AND news.time>'$startTime' AND news.time<'$stopTime'";
		$order      = 'news.time DESC';
		$this->checkList($countWhere,$dataWhere,$order);
		$this->assign('year',$year);
		$this->assign('month',$month);
		$this->assign('day',$day);
		/*输出日历*/
		import("@.ORG.Calendar");
		$cal = new Calendar($time);
		$getMonth = $cal->getMonth();
		$this->assign('getMonth',$getMonth);
		$getDay = $cal->getDay($startTime);
		$this->assign('getDay',$getDay);
		$this->display();
	}
	
	
	
	}
?>